/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.example.ejb;

import com.example.entity.MdlVideoconferenciacfg;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;

/**
 *
 * @author andres
 */
@Stateless
public class ConfigSession implements ConfigSessionLocal {
    @PersistenceContext(unitName = "Example-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    @Override
    public List<MdlVideoconferenciacfg> retrieve() {
        Query query = em.createNamedQuery("MdlVideoconferenciacfg.findAll");
        return query.getResultList();
    }

    @Override
    public MdlVideoconferenciacfg update(MdlVideoconferenciacfg vc) {
        return em.merge(vc);
    }

    @Override
    public void delete(MdlVideoconferenciacfg vc) {
        MdlVideoconferenciacfg config = em.merge(vc);
        em.remove(config);
    }

    @Override
    public void add(MdlVideoconferenciacfg config) {
        em.persist(config);
    }
}
